package example;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.WebApplicationInitializer;

import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

@Configuration
public class MyConfig implements WebApplicationInitializer {
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        ServletRegistration.Dynamic dispatcher1 = servletContext.addServlet("hello1", MyServlet1.class);
       dispatcher1.addMapping("/s1");
        ServletRegistration.Dynamic dispatcher2 = servletContext.addServlet("hello2", MyServlet2.class);
        dispatcher2.addMapping("/s2");
        ServletRegistration.Dynamic dispatcher3 = servletContext.addServlet("hello3", MyServlet3.class);
        dispatcher3.addMapping("/s3");

        FilterRegistration.Dynamic filter=servletContext.addFilter("MyFilter",MyFilter.class);
        filter.addMappingForUrlPatterns(null,false,"/*");
    }
}
